package com.ossean.match.model;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.InvalidPropertiesFormatException;
import java.util.List;
import java.util.Properties;

import org.apache.log4j.Logger;

public class Configure {

	private Properties prop = new Properties();
	Logger log4j = Logger.getLogger(Configure.class);
	private int startId;
	private int endId;
	private int batchSize;
	private boolean newComing;
    
    //自定义构造函数
    public Configure(String confPath) {
		confPath = confPath + ".xml";
		try {
			URL url = ClassLoader.getSystemResource(confPath);
			InputStream is = url.openStream();
			prop.loadFromXML(is);
		} catch (FileNotFoundException e) {
			log4j.error("Configure FileNotFoundException !");
			e.printStackTrace();
		} catch (InvalidPropertiesFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		config();
	}
    
    private void config() {
    	this.startId = Integer.parseInt(prop.getProperty("startId"));
    	this.endId = Integer.parseInt(prop.getProperty("endId"));
    	this.batchSize = Integer.parseInt(prop.getProperty("batchSize"));
    	this.newComing = Boolean.parseBoolean(prop.getProperty("newComing"));
        
	}
    
	public Properties getProp() {
		return prop;
	}
	public void setProp(Properties prop) {
		this.prop = prop;
	}
	public Logger getLog4j() {
		return log4j;
	}
	public void setLog4j(Logger log4j) {
		this.log4j = log4j;
	}

	public int getStartId() {
		return startId;
	}

	public void setStartId(int startId) {
		this.startId = startId;
	}

	public int getEndId() {
		return endId;
	}

	public void setEndId(int endId) {
		this.endId = endId;
	}

	public int getBatchSize() {
		return batchSize;
	}

	public void setBatchSize(int batchSize) {
		this.batchSize = batchSize;
	}

	public boolean isNewComing() {
		return newComing;
	}

	public void setNewComing(boolean newComing) {
		this.newComing = newComing;
	}
	
	
	
    
    
}
